package edu.ucsc.track_builder
{
	import flexunit.framework.TestCase;
	
	public class UtilityTest extends TestCase
	{
		public function test_distanceFromVelocityChange():void {
			var testData:Array = [
							[0.0, 0.0, 5, 5, 0],
							[0.0, 1.5, 5, 5, 0.82158383625774933],
							[0.0, 3.0, 5, 5, 2.3237900077244502],
							[0.0, 4.5, 5, 5, 4.2690748412273125],
							[0.0, 6.0, 5, 5, 6.5999999999999996],
							[0.0, 7.5, 5, 5, 9.375],
							[0.0, 9.0, 5, 5, 12.6],
							[0.0, 10.5, 5, 5, 16.274999999999999],
							[0.0, 12.0, 5, 5, 20.399999999999999],
							[0.0, 13.5, 5, 5, 24.975000000000001],
							[1.5, 0.0, 5, 5, 0.82158383625774922],
							[1.5, 1.5, 5, 5, 0],
							[1.5, 3.0, 5, 5, 2.4647515087732472],
							[1.5, 4.5, 5, 5, 4.6475800154489004],
							[1.5, 6.0, 5, 5, 7.1151247353788536],
							[1.5, 7.5, 5, 5, 9.8999999999999986],
							[1.5, 9.0, 5, 5, 13.125],
							[1.5, 10.5, 5, 5, 16.800000000000001],
							[1.5, 12.0, 5, 5, 20.925000000000001],
							[1.5, 13.5, 5, 5, 25.5],
							[3.0, 0.0, 5, 5, 2.3237900077244502],
							[3.0, 1.5, 5, 5, 2.4647515087732472],
							[3.0, 3.0, 5, 5, 0],
							[3.0, 4.5, 5, 5, 4.1079191812887457],
							[3.0, 6.0, 5, 5, 6.9713700231733515],
							[3.0, 7.5, 5, 5, 9.9611746295303956],
							[3.0, 9.0, 5, 5, 13.199999999999999],
							[3.0, 10.5, 5, 5, 16.875],
							[3.0, 12.0, 5, 5, 21.0],
							[3.0, 13.5, 5, 5, 25.575000000000003],
							[4.5, 0.0, 5, 5, 4.2690748412273125],
							[4.5, 1.5, 5, 5, 4.6475800154489004],
							[4.5, 3.0, 5, 5, 4.1079191812887457],
							[4.5, 4.5, 5, 5, 0],
							[4.5, 6.0, 5, 5, 5.7510868538042441],
							[4.5, 7.5, 5, 5, 9.2951600308978009],
							[4.5, 9.0, 5, 5, 12.807224523681938],
							[4.5, 10.5, 5, 5, 16.5],
							[4.5, 12.0, 5, 5, 20.625],
							[4.5, 13.5, 5, 5, 25.200000000000003],
							[6.0, 0.0, 5, 5, 6.6000000000000014],
							[6.0, 1.5, 5, 5, 7.1151247353788545],
							[6.0, 3.0, 5, 5, 6.9713700231733498],
							[6.0, 4.5, 5, 5, 5.7510868538042441],
							[6.0, 6.0, 5, 5, 0],
							[6.0, 7.5, 5, 5, 7.3942545263197417],
							[6.0, 9.0, 5, 5, 11.618950038622252],
							[6.0, 10.5, 5, 5, 15.653274417833476],
							[6.0, 12.0, 5, 5, 19.799999999999997],
							[6.0, 13.5, 5, 5, 24.375],
							[7.5, 0.0, 5, 5, 9.3750000000000018],
							[7.5, 1.5, 5, 5, 9.9000000000000004],
							[7.5, 3.0, 5, 5, 9.9611746295303956],
							[7.5, 4.5, 5, 5, 9.2951600308978009],
							[7.5, 6.0, 5, 5, 7.3942545263197417],
							[7.5, 7.5, 5, 5, 0],
							[7.5, 9.0, 5, 5, 9.037422198835241],
							[7.5, 10.5, 5, 5, 13.942740046346703],
							[7.5, 12.0, 5, 5, 18.499324311985017],
							[7.5, 13.5, 5, 5, 23.100000000000001],
							[9.0, 0.0, 5, 5, 12.6],
							[9.0, 1.5, 5, 5, 13.125],
							[9.0, 3.0, 5, 5, 13.199999999999999],
							[9.0, 4.5, 5, 5, 12.807224523681938],
							[9.0, 6.0, 5, 5, 11.618950038622252],
							[9.0, 7.5, 5, 5, 9.037422198835241],
							[9.0, 9.0, 5, 5, 0],
							[9.0, 10.5, 5, 5, 10.680589871350739],
							[9.0, 12.0, 5, 5, 16.266530054071154],
							[9.0, 13.5, 5, 5, 21.345374206136558],
							[10.5, 0.0, 5, 5, 16.274999999999999],
							[10.5, 1.5, 5, 5, 16.799999999999997],
							[10.5, 3.0, 5, 5, 16.875],
							[10.5, 4.5, 5, 5, 16.5],
							[10.5, 6.0, 5, 5, 15.653274417833476],
							[10.5, 7.5, 5, 5, 13.9427400463467],
							[10.5, 9.0, 5, 5, 10.680589871350739],
							[10.5, 10.5, 5, 5, 0],
							[10.5, 12.0, 5, 5, 12.323757543866236],
							[10.5, 13.5, 5, 5, 18.590320061795602],
							[12.0, 0.0, 5, 5, 20.399999999999995],
							[12.0, 1.5, 5, 5, 20.925000000000001],
							[12.0, 3.0, 5, 5, 20.999999999999996],
							[12.0, 4.5, 5, 5, 20.625],
							[12.0, 6.0, 5, 5, 19.800000000000001],
							[12.0, 7.5, 5, 5, 18.499324311985017],
							[12.0, 9.0, 5, 5, 16.266530054071151],
							[12.0, 10.5, 5, 5, 12.323757543866236],
							[12.0, 12.0, 5, 5, 0],
							[12.0, 13.5, 5, 5, 13.966925216381735],
							[13.5, 0.0, 5, 5, 24.974999999999998],
							[13.5, 1.5, 5, 5, 25.499999999999996],
							[13.5, 3.0, 5, 5, 25.574999999999999],
							[13.5, 4.5, 5, 5, 25.200000000000003],
							[13.5, 6.0, 5, 5, 24.375],
							[13.5, 7.5, 5, 5, 23.100000000000001],
							[13.5, 9.0, 5, 5, 21.345374206136558],
							[13.5, 10.5, 5, 5, 18.590320061795602],
							[13.5, 12.0, 5, 5, 13.966925216381735],
							[13.5, 13.5, 5, 5, 0]
						];
			for each (var td:Array in testData) {
				assertTrue(Math.abs(Utility.distanceFromVelocityChange(td[0],td[1],td[2],td[3]) - td[4]) < 1E-4);	
			}
		}

	}
}